function createFilterLabel(name,count,id){
	var label = $(document.createElement('div')).attr({
		"class" : "filterlabel"
	}).html(name);
	
	if(id != undefined)
		$(label).attr("id",id);
	
	if(count != undefined)
		label.html(name+" ("+count+")");
	
	return label;
};

function createSelectMenu(containerid, text, values, callback) {
	var container = $(document.createElement('div')).attr({
		"id" : containerid,
		"class": "selectcontainer"
	}).css("width","150px");

	var menuButton = $(document.createElement('div')).attr({
		"class" : "selectmenu",
		"id" : "select_"+containerid
	}).html(text);

	var menuArea = $(document.createElement('div')).attr({
		"id" : containerid + "_dd",
		"class" : "dropdown"
	}).css("display", "none");

	$(container).append(menuButton);
	$(container).append(menuArea);

	$(values).each(function() {
		var menuElement = $(document.createElement('div')).attr({
			"class" : "selectmenuElement"
		}).html(this.toString())
			.css("padding","0 0 0 5px");

		$(menuElement).click(function(event) {
			$(menuButton).html($(this).html());
			if (typeof callback == "function")
				callback(event);
		});

		$(menuArea).append(menuElement);
	});

	$(menuButton).click(function() {
		if ($(menuArea).css("display") == "none")
			$(menuArea).show();
		else
			$(menuArea).hide();
	});

	var mouse_is_inside = false;

	$('.dropdown').hover(function() {
		mouse_is_inside = true;
	}, function() {
		mouse_is_inside = false;
	});

	$("body").mouseup(function(event) {
		if (!mouse_is_inside && $(event.srcElement).attr("class") != "selectmenu")
			$('.dropdown').hide();
	});

	return container;
}
